import { request } from '@/utils/request/axios';
import { ErrorMessageMode, PageRequest, PageData } from '#/request';
import { DeviceVarStateOutputDto } from './model';

/** 设备变量状态枚举 */
enum Api {
  /** 读取设备变量状态 */
  Read = '/api/iot/admin/variableState/read',
  /** 删除设备变量状态 */
  Delete = '/api/iot/admin/variableState/delete',
}

//#region 读取设备变量状态
/**
 * 读取设备变量状态
 * @param params 分页请求
 * @param mode 错误消息模型
 */
export function readVariableState(params: PageRequest, mode: ErrorMessageMode = 'message') {
  return request.post<PageData<DeviceVarStateOutputDto>>(
    {
      url: Api.Read,
      params: params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
//#endregion
//#region 删除设备变量状态
/**
 * 删除设备变量状态
 * @param ids 设备变量状态编号
 * @param mode 错误消息模型
 */
export function deleteVariableState(ids: (string | bigint)[], mode: ErrorMessageMode = 'message') {
  return request.post(
    {
      url: Api.Delete,
      params: ids,
    },
    {
      errorMessageMode: mode,
    },
  );
}
//#endregion
